package org.unt.thread;

import org.apache.log4j.Logger;

public class TaskRunner extends Thread {

	private static Logger log = Logger.getLogger(TaskRunner.class.getCanonicalName());

	private String table;

	public TaskRunner(String table) {
		this.table = table;
	}

	public static int avaibleThreadsAmount = 3;

	public void run() {

		int millis = (int) (20000 * Math.random());
		log.info("Starting copy of " + table + ". Will take  " + (float) ((int) (millis / 100) / 10));

		Test.map.put(table, "OG");

		try {
			Thread.sleep(millis);
		} catch (InterruptedException e1) {
			e1.printStackTrace();
		}

		TaskRunner.avaibleThreadsAmount++;
		log.info("Finished copy of " + table);

		Test.map.put(table, "FI");
	}
}
